/*
make the order: {} -> [] ->()
( 5 6 4 ) [ 2 3 1 ] ( 8 9 7 )
( 8 9 7 ) [ 5 6 4 ] ( 2 3 1 )
( 2 3 1 ) [ 8 9 7 ] ( 5 6 4 )

[ 4 5 6 ] { 1 2 3 } [ 7 8 9 ]
[ 7 8 9 ] { 4 5 6 } [ 1 2 3 ]
[ 1 2 3 ] { 7 8 9 } [ 4 5 6 ]

( 6 4 5 ) [ 3 1 2 ] ( 9 7 8 )
( 9 7 8 ) [ 6 4 5 ] ( 3 1 2 )
( 3 1 2 ) [ 9 7 8 ] ( 6 4 5 )
 */
//get a 3*3 sudoku for get 9*9 sudoku
/*
function CreateSudokuRoot() {
    var root = new Array();
    for (var i = 0;i < 9; i++) {
        var n = 0;
        while (true) {
            //get a number
            n = Math.floor(Math.random() * 10);
            //check this number whether repeat
            if (root.length > 0) {
                for (let v in root) {
                    if (typeof v == "number" && n == v) {
                        continue;
                    }
                    else {
                        console.error("type error, typeof v is " + typeof v);
                    }
                }
            }
            break;
        }
        root.push(n);
    }
    var result = new Array();
    //slice to 3*3 two-dimension array from root array
    for (var i = 0; i < 3; i++) {
        result.push(root.slice(i * 3, i * 3 + 2));
    }
    return result;
}
//算法待定
function CreateSudokuRow(root) {
    var row1 = new Array();
    row1.push(root[1]);
    row1.push(root[2]);
    row1.push(root[0]);
    var row2 = new Array();
    row2.push(root[2]);
    row2.push(root[0]);
    row2.push(root[1]);
    var result = new Array();
    result.push(row1);
    result.push(root);
    result.push(row2);
    return result;
}
//算法待定
function CreateSudokuColumn(root) {
    var row1 = new Array();
    row1.push([root[0][1], root[0][2], root[0][0]]);
    row1.push([root[1][1], root[1][2], root[1][0]]);
    row1.push([root[2][1], root[2][2], root[2][0]]);
    var row2 = new Array();
    row1.push([root[0][2], root[0][0], root[0][1]]);
    row1.push([root[1][2], root[1][0], root[1][1]]);
    row1.push([root[2][2], root[2][0], root[2][1]]);
    var result = new Array();
    result.push(row1);
    result.push(root);
    result.push(row2);
    return result;
}
//算法待定
function CreateSudoku() {
    var root = CreateSudokuRoot();
    var columnRoot = CreateSudokuColumn(root);
    var row0 = CreateSudokuRow(columnRoot[0]);
    var row1 = CreateSudokuRow(columnRoot[1]);
    var row2 = CreateSudokuRow(columnRoot[2]);
    var result = new Array();
    result.push(row0);
    result.push(row1);
    result.push(row2);
    return result;
}
*/
function CreateSudokuMap(){
    var map = new Array();
    for(var i = 0; i < 81; i++){
        map.push(0);
    }
    return map
}

export default {
    data: {
        sudoku: null,
        title: 'World',
    },
    onInit() {
        this.sudoku = CreateSudokuMap();
    }
}
